import Vue from 'vue'
import Router from 'vue-router'

/* Layout */
import Layout from '../views/layout/Layout'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    title: 'title'               the name show in subMenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    breadcrumb: false            if false, the item will hidden in breadcrumb(default is true)
  }
 **/
/**
 * meta说明
 * code 权限标识
 * noSearch 是否不显示全局搜索框 true是不显示
 * pageQuery 地址栏参数需要保存，用于面包屑回跳
 * noLast 是否不显示末次统计 true是不显示
 * 注意：修改url和name时注意查找全局是否存在相应路由判断，同步修改
 */
export const constantRouterMap = [
    {path: '/login', component: () => import('@/views/login/index'), hidden: true},

    {
        path: '/',
        component: Layout,
        redirect: '/dashboard',
        name: 'Dashboard',
        hidden: true,
        children: [{
            path: 'dashboard',
            component: () => import('@/views/dashboard/index')
        }]
    },
    {
        path: '/org',
        component: Layout,
        redirect: '/org/index',
        name: 'Org',
        meta: {title: '机构管理', icon: 'org', code: 300001000000, noSearch: true, breadcrumb: false},
        children: [
            {
                path: 'index',
                name: 'OrgIndex',
                component: () => import('@/views/mechanism'),
                meta: {title: '机构管理', code: 300001000000, noSearch: true},
                hidden: true
            }
        ]
    },
    {
        path: '/user',
        component: Layout,
        redirect: '/user/index',
        name: 'User',
        meta: {title: '用户管理', icon: 'usermenu', code: 300002000000, noSearch: true, breadcrumb: false},
        children: [
            {
                path: 'index',
                name: 'UserIndex',
                component: () => import('@/views/user'),
                meta: {title: '用户管理', code: 300002000000, noSearch: true},
                hidden: true
            }
        ]
    },
    {
        path: '/auth',
        component: Layout,
        redirect: '/auth/index',
        name: 'Auth',
        meta: {title: '角色管理', icon: 'auth', code: 300003000000, noSearch: true, breadcrumb: false},
        children: [
            {
                path: 'index',
                name: 'AuthIndex',
                component: () => import('@/views/auth'),
                meta: {title: '角色管理', code: 300003000000, noSearch: true},
                hidden: true
            }
        ]
    },
    {
        path: '/department',
        component: Layout,
        redirect: '/department/index',
        name: 'Department',
        meta: {title: '科室管理', icon: 'department', code: 300004000000, noSearch: true, breadcrumb: false},
        children: [
            {
                path: 'index',
                name: 'DepartmentIndex',
                component: () => import('@/views/department'),
                meta: {title: '科室管理', code: 300004000000, noSearch: true},
                hidden: true
            }
        ]
    },
    {
        path: '/drg-settings',
        component: Layout,
        redirect: '/drg-settings/rule',
        name: 'DrgSettings',
        meta: {title: 'DRG设置', icon: 'drgset', code: 300005000000, noSearch: true},
        children: [
            {
                path: 'params',
                name: 'DrgSettingsParams',
                component: () => import('@/views/drg-settings/param-setting'),
                meta: {title: 'DRG参数设置', code: 300005003000, noSearch: true}
            },
            {
                path: 'rule',
                name: 'DrgSettingsRule',
                component: () => import('@/views/drg-settings/exclude-rules'),
                meta: {title: '排除组规则', code: 300005001000, noSearch: true}
            },
            {
                path: 'group',
                name: 'DrgSettingsGroup',
                component: () => import('@/views/drg-settings/drg-group'),
                meta: {title: 'DRGs组管理', code: 300005002000, noSearch: true}
            }
        ]
    },
    {
        path: '/qc-settings',
        component: Layout,
        redirect: '/qc-settings/rule',
        name: 'QCSettings',
        meta: {title: '质控设置', icon: 'qcset', code: 300006000000, noSearch: true},
        children: [
            {
                path: 'rule',
                name: 'QCSettingsRate',
                component: () => import('@/views/qc-settings/custom-rating'),
                meta: {title: '自定义评分维护', code: 300006001000, noSearch: true}
            },
            {
                path: 'group',
                name: 'QCSettingsRule',
                component: () => import('@/views/qc-settings/rule-base'),
                meta: {title: '规则库更新', code: 300006002000, noSearch: true}
            }
        ]
    },
    {
        path: '/config',
        component: Layout,
        redirect: '/config/index',
        name: 'Config',
        meta: {title: '系统参数设置', icon: 'config', code: 300007000000, noSearch: true, breadcrumb: false},
        children: [
            {
                path: 'index',
                name: 'ConfigIndex',
                component: () => import('@/views/param-config'),
                meta: {title: '系统参数设置', code: 300007000000, noSearch: true},
                hidden: true
            }
        ]
    },
    {
        path: '/basic-data',
        component: Layout,
        redirect: '/basic-data/rule',
        name: 'BasicData',
        meta: {title: '基础数据', icon: 'basicdata', code: 300008000000, noSearch: true},
        children: [
            {
                path: 'position',
                name: 'BasicDataPosition',
                component: () => import('@/views/basic-data/position'),
                meta: {title: '职务管理', code: 300008001000, noSearch: true}
            },
            {
                path: 'title',
                name: 'BasicDataTitle',
                component: () => import('@/views/basic-data/job-title'),
                meta: {title: '职称管理', code: 300008002000, noSearch: true}
            }
        ]
    },
    {
        path: '/feedback',
        component: Layout,
        redirect: '/feedback/index',
        name: 'Feedback',
        meta: {title: '意见反馈', icon: 'feedback', code: 300009000000, noSearch: true, breadcrumb: false},
        children: [
            {
                path: 'index',
                name: 'FeedbackIndex',
                component: () => import('@/views/feedback'),
                meta: {title: '意见反馈', code: 300009000000, noSearch: true},
                hidden: true
            }
        ]
    },
    {
        path: '/introduction',
        component: Layout,
        redirect: '/introduction/index',
        name: 'Introduction',
        meta: {title: '产品介绍', noSearch: true},
        hidden: true,
        children: [
            {
                path: 'index',
                name: 'Intor',
                component: () => import('@/views/introduction'),
                meta: {title: '', noSearch: true},
                hidden: true
            }
        ]
    }
]

export default new Router({
    mode: 'history', // 后端支持可开
    base: 'mrms', // 这里设置的是部署在子站点的名字
    scrollBehavior: () => ({y: 0}),
    routes: constantRouterMap
})
